/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model.doctor;

import entities.DoctorDetails;
import java.util.ArrayList;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableModel;

/**
 *
 * @author Admin
 */
public class DoctorTableModel implements TableModel {

    private String[] header;
    private ArrayList<DoctorDetails> rowsData;

    public DoctorTableModel(ArrayList<DoctorDetails> rowsData) {
        this.rowsData = rowsData;
    }

    public String[] getHeader() {
        return header;
    }

    public void setHeader(String[] header) {
        this.header = header;
    }

    public ArrayList<DoctorDetails> getRowsData() {
        return rowsData;
    }

    public void setRowsData(ArrayList<DoctorDetails> rowsData) {
        this.rowsData = rowsData;
    }

    @Override
    public int getRowCount() {
        if (rowsData != null) {
            return rowsData.size();
        } else {
            return 0;
        }
    }

    @Override
    public int getColumnCount() {
        return header.length;
    }

    @Override
    public String getColumnName(int columnIndex) {
        return header[columnIndex];
    }

    @Override
    public Class<?> getColumnClass(int columnIndex) {
        if (columnIndex == 5) {
            return Boolean.class;
        } else {
            return String.class;
        }
    }

    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return false;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        if (rowsData != null && rowsData.size() > rowIndex) {
            DoctorDetails d = rowsData.get(rowIndex);
            switch (columnIndex) {
                case 0:
                    return d.getdUsername();
                case 1:
                    return d.getdFName() + " " + d.getdLName();
                case 2:
                    return d.getdAddress();
                case 3:
                    return d.getdPhone();
                case 4:
                    return d.getdSpecialization();
                case 5:
                    return d.isdGender();
            }
        }
        return null;
    }

    @Override
    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
        //throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void addTableModelListener(TableModelListener l) {
        //throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void removeTableModelListener(TableModelListener l) {
        //throw new UnsupportedOperationException("Not supported yet.");
    }
}
